<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <body>

        <ui:composition template="./template.xhtml">

            <ui:define name="title">
                List Users
            </ui:define>

            <ui:define name="content">
                <h:form>
                    <p:dataTable var="u" value="#{listUsersBean.use}" id="datatable" rows="20" resizableColumns="false">
                        <f:facet name="header">
                            List Users
                        </f:facet>
                        <p:column headerText="Fullname">
                            <h:link outcome="userDetail" value="#{u.username}">
                                <f:param name="userid" value="#{u.userID}" />
                            </h:link>
                        </p:column>
                        <p:column headerText="Date Create">
                            <h:link outcome="userDetail">
                                <h:outputText value="#{u.createDate}">
                                    <f:convertDateTime pattern="dd/MM/yyyy" />
                                </h:outputText>
                                <f:param name="userid" value="#{u.userID}" />
                            </h:link>
                        </p:column>
                        <p:column headerText="Gender">
                            <h:link outcome="userDetail" value="#{u.gender}">
                                <f:param name="userid" value="#{u.userID}" />
                            </h:link>
                        </p:column>
                        <p:column headerText="Email" >
                            <h:link outcome="userDetail" value="#{u.email}">
                                <f:param name="userid" value="#{u.userID}" />
                            </h:link>
                        </p:column>
                        <p:column headerText="Phone">
                            <h:link outcome="userDetail" value="#{u.phone}">
                                <f:param name="userid" value="#{u.userID}" />
                            </h:link>
                        </p:column>
                        <p:column headerText="Status">
                            <h:link outcome="userDetail">
                                <h:outputText value="#{u.status}">
                                    <f:converter converterId="UserStatus" />
                                </h:outputText>
                                <f:param name="userid" value="#{u.userID}" />
                            </h:link>
                        </p:column>
                        <p:column headerText="Acction">
                            <p:commandButton value="Activate" rendered="#{u.status==false}" action="#{listUsersBean.activate}" >
                                <f:setPropertyActionListener value="#{u}" target="#{listUsersBean.user}" />
                            </p:commandButton>
                            <p:commandButton value="Deactivate" rendered="#{u.status==true}" action="#{listUsersBean.deactivate}" >
                                <f:setPropertyActionListener value="#{u}" target="#{listUsersBean.user}" />
                            </p:commandButton>
                        </p:column>
                    </p:dataTable>
                    <p:commandButton value="Add User" action="addUser.xhtml?faces-redirect=true" />
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
